#ifndef QQ_STORAGE
#define QQ_STORAGE

/*
#include <functional>
#include <memory>
#include <qapplication.h>
#include <qfuture.h>
#include <qfuturewatcher.h>
#include <qmutex.h>
#include <qobject.h>
#include <qreadwritelock.h>
#include <QtConcurrent>
#include <qatomic.h>
#include <qtimer.h>

#include <boost/lockfree/spsc_queue.hpp>

#include "api/QQSystemApi.h"

class QQTimerThread :public QThread
{
	Q_OBJECT
public:
	QQTimerThread(QObject* parent = nullptr);
	void setTimerInterval(int interval);
	void setTimeOutFunction(const std::function<void()>& func);
	void run() override;
private:
	QTimer* mTimer;
	std::function<void()> mFunc;
};

class QQThreadPool : public QObject
{
	Q_OBJECT
public:
	enum FinishType
	{
		Success,
		Error,
		TimeOut,
		Unknow
	};
public:
	explicit QQThreadPool(int threadCount = QThread::idealThreadCount(), QObject* parent = nullptr);
	~QQThreadPool();

	void setWorkerTimeout(int timeOut);
	int getWorkerTimeout() const;
	void setWorkerThreadCount(int threadCount);
	int getWorkerThreadCount() const;

	template <typename Worker, typename... Args>
	QFuture<QQThreadPool::FinishType> submit(Worker&& worker, Args&&... args);

	template<typename Worker, typename Return, typename ...Args>
	auto submitNeedReturn(Worker&& worker, Return&& value, Args && ...args) -> typename std::enable_if<std::is_reference<Return>::value, QFuture<QQThreadPool::FinishType>>::type;

private slots:
	void onFutureFinished();
private:
	void waitAllWorkerFinished();
private:
	int mTimeOut;
	int mThreadCount;
	QMutex mMutex;
	QMap<QFuture<QQThreadPool::FinishType>, QQTimerThread*> mTimerThreads;
	QList<QFutureWatcher<QQThreadPool::FinishType>*>mutable mFutureWatchers;
};

class QQStorageReadThread : public QThread
{
	Q_OBJECT
public:
	QQStorageReadThread(QObject* parent = nullptr);
	~QQStorageReadThread();

	void submit(const std::function<void()>& work);
	void stop();
protected:
	void run()  override;
private:
	std::function<void()> mRead;
};

class QQStorageReadThreadPool : public QObject
{
	Q_OBJECT
public:
	explicit QQStorageReadThreadPool(int threadCount = QThread::idealThreadCount(), QObject* parent = nullptr);
	~QQStorageReadThreadPool();

	void submit(const std::function<void()>& work);
	void setReadWriteLock(QReadWriteLock* readWriteLock);
private:
	QList<QQStorageReadThread*> mReadThreads;
	QQueue<std::function<void()>> mReadWorks;
	QAtomicInteger<bool> mIsStop = false;
	QWaitCondition mWaitCondition;
	QMutex mMutex;
	QReadWriteLock* mReadWriteLock;
};

class QQStorageWriteThread : public QThread
{
	Q_OBJECT
public:
	QQStorageWriteThread(QObject* parent = nullptr);
	~QQStorageWriteThread();
	void submit(const std::function<void()>& work);
	void setReadWriteLock(QReadWriteLock* readWriteLock);
	void stop();
protected:
	void run() override;
private:
	boost::lockfree::spsc_queue<std::function<void()>> mWriteWorks;
	QAtomicInteger<bool> mIsStop = false;
	QReadWriteLock* mReadWriteLock;
};

class QQStorage : public QObject
{
	Q_OBJECT
private:
	QQStorage(QObject* parent = nullptr);
	~QQStorage();
public:
	static QQStorage* getInstance();
	void init();
private:
	QReadWriteLock* mReadWriteLock;
	QQStorageReadThreadPool* mReadThreadPool;
	QQStorageWriteThread* mWriteThread;
};
*/

#endif // !QQ_STORAGE
